package com.project.myPackage.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.project.myPackage.entity.Comments;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import java.util.Map;

@Mapper
public interface CommentsMapper extends BaseMapper<Comments> {
    // 根据商品id获取商品所有评论信息 关联用户表 时间升序
   @Select("SELECT c.*, u.username  " +
           "FROM comments c " +
           "JOIN users u ON c.user_id = u.user_id " +
           "WHERE c.product_id = #{product_id} " +
           " ORDER BY c.created_at ASC")
    List<Map<String,Object>> getList(Integer product_id);
}
